<!doctype html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:include="include :: header"></head>
<body>
<div style="padding: 15px">
    <form class="layui-form" action="">
        <input id="treeId" name="parentId" type="hidden" th:value="${menu.menuId}"/>
        <div class="layui-row">
            <div class="layui-col-xs12">
                <div class="layui-form-item">
                    <label class="layui-form-label">上级菜单</label>
                    <div class="layui-input-inline">
                        <input class="layui-input" type="text" onclick="selectMenuTree()" id="treeName" readonly="true"
                               th:value="${menu.menuName}"/>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">菜单名称</label>
                        <div class="layui-input-inline">
                            <input type="text" name="menuName" lay-verify="required" autocomplete="off"
                                   class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">菜单类型</label>
                        <div class="layui-input-inline">
                            <select name="menuType" id="menuType" lay-verify="required" lay-search="">
                                <option value="M">目录</option>
                                <option value="C">菜单</option>
                                <option value="F">按钮</option>
                            </select>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">请求地址</label>
                        <div class="layui-input-inline">
                            <input type="text" name="url" lay-verify="required" autocomplete="off"
                                   class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">权限标识</label>
                        <div class="layui-input-inline">
                            <input type="text" name="perms" autocomplete="off"
                                   class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">图标名称</label>
                        <div class="layui-input-inline">
                            <input type="text" name="icon" autocomplete="off"
                                   class="layui-input">
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">显示排序</label>
                        <div class="layui-input-inline">
                            <input type="text" name="orderNum" lay-verify="required" autocomplete="off"
                                   class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">菜单状态</label>
                        <div class="layui-input-inline">
                            <select name="visible" id="visible" lay-verify="required" lay-search="">
                                <option value="0">显示</option>
                                <option value="1">隐藏</option>
                            </select>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit="" lay-filter="menu">立即提交</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>
        </div>
    </form>
</div>
<div th:include="include :: footer"></div>
<script type="text/javascript" th:src="@{/jquery-ztree/js/jquery.ztree.all-3.5.js}"></script>
<script th:inline="javascript">
    /*<![CDATA[*/
    var sysUrl = '/venus/system/menu';
    layui.use(['form'], function () {
        var form = layui.form;
        form.on('submit(menu)', function (data) {
            save(sysUrl, 'add', data.field);
            return false;
        });
    });

    //选择上层菜单
    function selectMenuTree() {
        var treeId = $("#treeId").val();
        var menuId = treeId > 0 ? treeId : 1;
        var url = sysUrl + "/selectMenuTree/" + menuId;
        layer.open({
            type: 2,
            area: ['280px', ($(window).height() - 50) + 'px'],
            fix: true, //不固定
            maxmin: false,
            shadeClose: true,
            shade: 0.4,
            title: '选择菜单',
            content: url,
            btn: ['选择', '关闭'],
            yes: function (index, layero) {
                var body = layer.getChildFrame('body', index);
                $("#treeId").val(body.find('#treeId').val());
                $("#treeName").val(body.find('#treeName').val());
                layer.close(index);
            }, cancel: function () {
                return true;
            }
        });
    }

    /*]]>*/
</script>
</body>
</html>